<?php

class FriendController extends Zend_Controller_Action
{
    public function init()
    {
        parent::init();

        if (Zend_Auth::getInstance()->hasIdentity())
        {
            $user = Zend_Auth::getInstance()->getIdentity();

            $this->view->userProfile = $user->profile;
            
        }
        else
            $this->_redirect('/index');
    }

    public function indexAction()
    {
        $this->view->friends = Friendship::findAllFriends();
        
        $this->view->requesters = Friendship::findAllRequesters();
    }
    
    public function searchAction()
    {
        
        $name = $this->_getParam('name');
        $surname = $this->_getParam('surname');
        $email = $this->_getParam('email');
        
        $search = User::findAllByParams($name, $surname, $email);
        
        $this->view->users = $search;
        
    }
}
